# =====================
# ==== COPY CONFIG ====
# =====================

mkdir ~/.pip

cp my_config_file/my_authorized_keys ~/.ssh/authorized_keys
cp my_config_file/my_autostart_sh ~/autostart.sh
cp my_config_file/my_gitconfig ~/.gitconfig
cp my_config_file/my_pip_conf ~/.pip/pip.conf
cp my_config_file/my_xmodmap ~/.Xmodmap
cp my_config_file/my_zshrc ~/.zshrc

sudo cp my_config_file/my_autostart_service /usr/lib/systemd/system/my_autostart.service

sh -c "cat my_config_file/my_bashrc_append >> ~/.bashrc"

sudo sh -c "echo \"Port 22
PermitRootLogin yes
PasswordAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys .ssh/authorized_keys2
ClientAliveInterval 30
ClientAliveCountMax 20
AllowUsers chli\" >> /etc/ssh/sshd_config"

sh -c "echo 'TZ='Asia/Shanghai'; export TZ' >> ~/.profile"

sudo chmod 600 ~/.ssh/authorized_keys

# ================
# ==== SOURCE ====
# ================

# close beem noise
sudo xset b off

# update pacman source
sudo pacman-mirrors -i -c China -m rank
sudo vi /etc/pacman.conf

sudo sh -c "echo '
[archlinuxcn]
SigLevel = Optional TrustedOnly
#中科大源
Server = https://mirrors.ustc.edu.cn/archlinuxcn/\$arch
#清华源
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/\$arch

#[antergos]
#SigLevel = TrustAll
#Server = https://mirrors.tuna.tsinghua.edu.cn/antergos/\$repo/\$arch

[arch4edu]
SigLevel = TrustAll
Server = https://mirrors.tuna.tsinghua.edu.cn/arch4edu/\$arch
' >> /etc/pacman.conf"

sh -c "echo '
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=\"@im=fcitx\"
' >> ~/.xprofile"

sudo pacman-mirrors -g
sudo pacman -Syyu
#sudo pacman -Sy antergos-keyring
sudo pacman -Sy archlinuxcn-keyring

# install requirements
sudo pacman -S yay
yay -S base-devel

# =============
# ==== YAY ====
# =============

yay -S \
  cmake gcc \
  adobe-source-code-pro-fonts wqy-bitmapfont wqy-microhei wqy-zenhei wqy-microhei-lite \
  fcitx fcitx-im fcitx-configtool fcitx-googlepinyin \
  bluez bluez-utils pulseaudio-bluetooth pavucontrol pulseaudio-alsa \
  wget curl git file htop net-tools \
  perl-local-lib zsh \
  pkg-config libxcb alacritty \
  lazygit ranger \
  aur/autojump \
  clang ctags \
  nodejs yarn npm python-pip neovim tmux \
  bedstead-fonts-powerline \
  minicom android-tools \
  flameshot \
  qv2ray \
  utools \
  microsoft-edge-dev-bin \
  netease-cloud-music \
  com.qq.weixin.deepin com.qq.im.deepin

# =================
# ==== INSTALL ====
# =================

systemctl enable my_autostart.service
sudo systemctl restart sshd

npm config set registry https://registry.npm.taobao.org
sudo npm install -g neovim pyright

PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib

sudo sh -c "echo '
load-module module-bluetooth-policy
load-module module-bluetooth-discover
' >> /etc/pulse/system.pa"

# pip
pip3 install -U pynvim neovim jedi-language-server

# bluetooth
sudo systemctl enable bluetooth
sudo systemctl start bluetooth
pulseaudio -k # 确保没有pulseaudio启动
pulseaudio --start # 启动pulseaudio服务

# autostart
sudo sh -c "echo '
[Policy]
AutoEnable=true' >> /etc/bluetooth/main.conf"

# echo "power on" | bluetoothctl
# my HHKB
# echo "pair D7:B8:67:05:95:CB" | bluetoothctl
# echo "connect D7:B8:67:05:95:CB" | bluetoothctl

# anaconda
wget https://repo.anaconda.com/archive/Anaconda3-5.3.1-Linux-x86_64.sh
sh Anaconda3-5.3.1-Linux-x86_64.sh

